<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>修改 - Powered by __CAOZHA-SYS-NAME__ __CAOZHA-SYS-VERSION__</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="__CAOZHA-LAYUIMINI__/lib/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="__CAOZHA-LAYUIMINI__/css/public.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
    <script src="__CAOZHA-STATIC__/js/jquery-3.4.1.min.js"></script>
    <script src="__CAOZHA-LAYUIMINI__/lib/layui/layui.js" charset="utf-8"></script>
    <script src="__CAOZHA-STATIC__/js/all.js"></script>
    <link rel="stylesheet" href="__CAOZHA-STATIC__/css/style.css" media="all">
</head>
<body>
<form class="layui-form layuimini-form">


    <div class="layui-form-item">
        <label class="layui-form-label required">链接名称</label>
        <div class="layui-input-block">
            <input type="text" name="link_name" lay-verify="required" lay-reqtext="链接名称不能为空" placeholder="请输入链接名称" value="{$links.link_name}"
                   class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label required">链接URL</label>
        <div class="layui-input-block">
            <input type="text" name="link_url" lay-verify="required" lay-reqtext="链接URL不能为空" placeholder="请输入链接URL" value="{$links.link_url}"
                   class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">链接图片</label>
        <div class="layui-input-block">
            <input type="text" name="link_img" placeholder="请输入链接图片" value="{$links.link_img}"
                   class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label required">排序</label>
        <div class="layui-input-block">
            <input type="number" name="listorder" lay-verify="required" lay-reqtext="请输入排序的数值" placeholder="请输入数值" value="{$links.listorder}"
                   class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label required">选择状态</label>
        <div class="layui-input-block">
            <select name="status" lay-verify="required" lay-reqtext="请选择文章状态">
                <option value=""></option>
                {foreach $links_status as $key=>$vo }
                <option value="{$key}"{if $key==$links.status} selected{/if}>{$vo}</option>
                {/foreach}
            </select>
        </div>
    </div>

    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">备注信息</label>
        <div class="layui-input-block">
            <textarea name="remarks" class="layui-textarea" placeholder="请输入备注信息">{$links.remarks}</textarea>
        </div>
    </div>

    <div class="layui-form-item" style="display: none">
        <div class="layui-input-block">
            <button type="submit" class="layui-btn caozha-submit" lay-submit="" lay-filter="saveBtn">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary caozha-reset">重置</button>
        </div>
    </div>
    <input type="hidden" name="id" value="{$links.id}">

</form>
<script src="__CAOZHA-LAYUIMINI__/lib/layui/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form'], function () {
        var form = layui.form,
            layer = layui.layer;

            layer_skin(layer);

        //监听提交
        form.on('submit(saveBtn)', function (data) {

            $.ajax({
                type: "post",
                url: '{:dc_url(\'admin/links/editSave\')}',
                data: data.field,
                dataType: "json",
                async: false,
                success: function (res) {
                    if (res.code == 1) {
                        layer.msg(res.msg, {icon: 1});
                        setTimeout(function(){
                            // 关闭弹出层
                            //layer.close(index);
                            var iframeIndex = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(iframeIndex);
                            parent.location.reload();
                        },800);
                    } else {
                        layer.msg(res.msg, {icon: 2});
                    }
                },
                complete: function (res) {
                }
            });

            return false;
        });

    });

</script>
</body>
</html>